package com.afkt.project.ui.widget.stickyheaders.tools;

import com.afkt.project.ui.widget.stickyheaders.model.HeaderModel;
import com.afkt.project.ui.widget.stickyheaders.model.ItemModel;
import com.dev.utils.DateUtils;
import com.dev.utils.TimeUtils;
import ohos.global.icu.util.Calendar;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Utils {
    private static final String TAG = "StickyHeaders";
    private static HiLogLabel sLogLabel;
    private static final int DOMAIN = 0x001;

    private static HiLogLabel createLogLabel() {
        if (sLogLabel == null) {
            sLogLabel = new HiLogLabel(HiLog.LOG_APP, DOMAIN, TAG);
        }
        return sLogLabel;
    }

    public static void info(String format, Object... objects) {
        HiLog.info(createLogLabel(), format, objects);
    }

    public static void debug(String format, Object... objects) {
        HiLog.debug(createLogLabel(), format, objects);
    }

    public static void error(String format, Object... objects) {
        HiLog.error(createLogLabel(), format, objects);
    }

    public static void warn(String format, Object... objects) {
        HiLog.warn(createLogLabel(), format, objects);
    }

    public static void fatal(String format, Object... objects) {
        HiLog.fatal(createLogLabel(), format, objects);
    }

    public static List<ItemModel> demoList() {
        List<ItemModel> items = new ArrayList<>();
        ItemModel itemModel = null;
        Calendar calendar = Calendar.getInstance();
        int b=0;
        for (int i = 0; i < 100; i++) {
            if (i == 0 || i == 2 || i % 4 == 0) {
                if(i==0){
                    itemModel = new HeaderModel("今天", "");
                }else{
                    calendar.add( Calendar.DATE, -(b++)); //向前走一天
                    itemModel = new HeaderModel((calendar.get(Calendar.MONTH)+1)+"月"+calendar.get(Calendar.DAY_OF_MONTH)+"日", "");
                }


            } else {
                if(i==1){
                    itemModel = new ItemModel("列表详情Item at " + i,  "今天");
                }else{
                    itemModel = new ItemModel("列表详情Item at " + i,  calendar.get(Calendar.YEAR)+"."+(calendar.get(Calendar.MONTH)+1)+"."+calendar.get(Calendar.DAY_OF_MONTH));
                }
            }
            items.add(itemModel);
        }
        return items;
    }

}
